{% extends 'base_backend.html' %}
{% load static %}
{% load my_filter %}
{% block header_tail %}
    <link rel="stylesheet" href="{% static 'public/CodeMirror/lib/codemirror.css' %}">
    <link rel="stylesheet" href="{% static 'public/ComboSelect/css/combo.select.css' %}">
    <link rel="stylesheet" href="{% static 'public/CodeMirror/theme/lesser-dark.css' %}">
    <link rel="stylesheet" href="{% static 'public/CodeMirror/addon/dialog/dialog.css' %}">
    <link rel="stylesheet" href="{% static 'public/CodeMirror/addon/search/matchesonscrollbar.css' %}">
    <link rel="stylesheet" href="{% static 'plugins/select2/select2.css' %}">
    <link rel="stylesheet" href="{% static 'public/ComboSelect/css/combo.select.css' %}">
    <link rel="stylesheet" href="{% static 'zhongbao/config/css/main.css' %}">
    <script src="{% static 'plugins\jQuery\jquery-2.2.3.min.js' %}"></script>
    <script src="{% static 'plugins/vue1/vue.js' %}"></script>

    <style>
        .login-banner {
            width: 100%;
            background: url("{% static 'public/img/banner2.jpg' %}") center bottom/cover no-repeat;
        }
    </style>
{% endblock header_tail %}

{% block section_content %}
    <div>
        <div class="box-header with-border">
            <h3 class="box-title">{{ model_verbose_name }}</h3>
        </div>
        <!-- form start -->
        <div class="box box-primary">
            <div class="box-body">
                <input class="no-display" type="text">
                <p style="clear: both"></p>
                <div>
                    <div style="float: left;" class="input-group select-config-div">
                        <label for="id" class="control-label">任务ID：</label>
                        <p id="taskId" type="text" class="config-input">{{ task.id }}</p>
                    </div>
                    <div style="float: left;" class="input-group select-config-div">
                        <label for="id" class="control-label">项目ID：</label>
                        <p type="text" class="config-input">{{ task.project_id }}</p>
                    </div>
                    <div style="float: left;" class="input-group select-config-div">
                        <label for="id" class="control-label">网站名称：</label>
                        <p type="text" class="config-input">{{ task.site_name }}</p>
                    </div>
                    <div style="float: left;" class="input-group select-config-div">
                        <label for="id" class="control-label">网站URL：</label>
                        <p type="text" class="config-input">{{ task.site_url }}</p>
                    </div>
                    <div style="float: left;" class="input-group select-config-div">
                        <label for="id" class="control-label">域名：</label>
                        <p type="text" class="config-input">{{ task.domain }}</p>
                    </div>
                    <div style="float: left;" class="input-group select-config-div">
                        <label for="id" class="control-label">一级域名：</label>
                        <p type="text" class="config-input">{{ task.first_domain }}</p>
                    </div>
                    <div style="float: left;" class="input-group select-config-div">
                        <label for="id" class="control-label">分配时间：</label>
                        <p type="text" id="allocation_flag" class="config-input"></p>
                    </div>
                    <div style="float: left;" class="input-group select-config-div">
                        <label for="id" class="control-label">通过时间：</label>
                        <p id="finish_flag" type="text" class="config-input"></p>
                    </div>
                    <div style="float: left;" class="input-group select-config-div">
                        <label for="id" class="control-label">任务备注：</label>
                        <p type="text" class="config-input">{{ task.note }}</p>
                    </div>
                    <div style="float: left;" class="input-group select-config-div">
                        <label for="id" class="control-label">录入时间：</label>
                        <p type="text" id="ctime" class="config-input"></p>
                    </div>
                    <div style="float: left;" class="input-group select-config-div">
                        <label for="id" class="control-label">用户ID：</label>
                        <p type="text" class="config-input">{{ task.uid }}</p>
                    </div>
                    <div style="float: left;" class="input-group select-config-div">
                        <label for="id" class="control-label">网站国家：</label>
                        <p type="text" class="config-input">
                            {% if task.country %}
                                {{ task.country }}
                            {% else %}

                            {% endif %}
                        </p>
                    </div>
                    <div style="float: left;" class="input-group select-config-div">
                        <label for="id" class="control-label">网站语言：</label>
                        <p type="text" class="config-input">{{ task.lang }}</p>
                    </div>
                    <div style="float: left;" class="input-group select-config-div">
                        <label for="id" class="control-label">任务描述：</label>
                        <p type="text" class="config-input">{{ task.description }}</p>
                    </div>
                    <div style="float: left;" class="input-group select-config-div">
                        <label for="id" class="control-label">任务状态：</label>
                        <p type="text" class="config-input">{{ task.description }}</p>
                    </div>
                    <div style="float: left;" class="input-group select-config-div">
                        <label for="id" class="control-label">ICP：</label>
                        <p type="text" class="config-input">{{ task.icp }}</p>
                    </div>
                    <div style="float: left;" class="input-group select-config-div">
                        <label for="id" class="control-label">管控平台任务描述：</label>
                        <p type="text" class="config-input">{{ task.gk_description }}</p>
                    </div>
                    <div style="float: left;" class="input-group select-config-div">
                        <label for="id" class="control-label">管控平台任务备注：</label>
                        <p type="text" class="config-input">{{ task.gk_remark }}</p>
                    </div>

                    <div style="float: left;" class="input-group select-config-div">

                        <p><a href="{% url 'maintain:config_change' task.id %}" class="btn btn-success">详情</a></p>
                        <p><a href="{% url 'maintain:debug_config' task.id %}" class="btn btn-success"
                              target="_blank">测试</a>
                        </p>

                    </div>
                    {% if task.is_affirm == 1 or user.is_superuser  or  user.is_agent %}
                        <div style="float: left;" class="input-group select-config-div">
                            {#                        <p><a href="{% url 'maintain:change_history' task.id %}" class="btn btn-success"#}
                            {#                              target="_blank">代码历史</a></p>#}
                            <p class="btn btn-primary" onclick="code_1()">代码对比</p>
                            <p><a href="{% url 'maintain:data_size' task.id %}" class="btn btn-success" target="_blank">数据量统计</a>
                            </p>
                        </div>


                        <div style="float: left;" class="input-group select-config-div">
                            <p id="test_maintain_config" class="btn btn-primary"
                               onclick="test_maintain_config({{ task.id }})">测试配置</p>
                        </div>

                    {% endif %}
                    {% if task.status.code == 5 and task.is_affirm == 0  and not user.is_superuser  and not user.is_agent %}
                        <p class="btn btn-primary" onclick="alarms_fail({{ task.id }})">申请重审</p>
                        <p class="btn btn-primary" onclick="task_affirm({{ task.id }})">确认不合格</p>
                    {% endif %}
                    {% if user.agency.id == 1 %}
                        <div style="float: left;" class="input-group select-config-div">
                            <p><a href="http://ispider.istarshine.com/config/{{ task.config_id }}/change/"
                                  class="btn btn-success" target="_blank">采集后台</a></p>
                        </div>
                    {% endif %}
                    {% if user.is_superuser %}
                        <div style="float: left;" class="input-group select-config-div">
                            <p><a href="{% url 'maintain:operating_record' 'task' %}?id={{ task.id }}"
                                  class="btn btn-success" target="_blank">任务操作记录</a></p>
                        </div>
                    {% endif %}
                </div>
                <!--  新增配置列表 start  -->
                <div class="row">
                    <div class="col-md-12">
                        <!-- DIRECT CHAT -->
                        <div class="box box-primary direct-chat direct-chat-primary">
                            <div class="box-header with-border">
                                <div style="float: left;" class="input-group select-config-div">
                                    <label for="">新增配置列表：</label>
                                </div>
                                <div style="float: left;" class="input-group select-config-div">
                                    {% if task.status.code == 2 or task.status.code == 5 or task.status.code == 10 %}
                                        {% if task.is_affirm == 1 or user.is_superuser  or  user.is_agent %}
                                            <a href="{% url 'maintain:add_config' %}?tid={{ task.id }}"
                                               class="btn btn-info btn-xs" tag="1" id="config-add">添加配置</a>
                                        {% endif %}
                                    {% endif %}
                                </div>
                                <div class="box-tools pull-right">
                                <span data-toggle="tooltip" title="{{ communicatesNum }} Messages"
                                      class="badge bg-blue">{{ new_config_count }}</span>
                                    <button type="button" class="btn btn-box-tool" data-widget="collapse"><i
                                            class="fa fa-plus"></i>
                                    </button>
                                </div>
                            </div>
                            <div class="box-body">
                                <table id="auditRecordTable" border="1"
                                       class="table table-bordered table-hover table-striped">
                                    <thead>
                                    <tr>
                                        <th class="action-checkbox">
                                        <span style="float: left">
                                            新增配置ID
                                        </span>
                                        </th>
                                        <th class="action-checkbox">
                                        <span style="float: left">
                                            文件名称
                                        </span>
                                        </th>
                                        <th style="width: 350px;">
                                        <span style="float: left">
                                            创建时间
                                        </span>
                                        </th>
                                        <th style="width: 350px;">
                                        <span style="float: left">
                                            最后修改时间
                                        </span>
                                        </th>
                                        <th style="width: 350px;">
                                        <span style="float: left">
                                            创建人
                                        </span>
                                        </th>
                                        <th>
                                        <span style="float: left">
                                            操作
                                        </span>
                                        </th>

                                    </tr>
                                    </thead>
                                    <tbody>
                                    {% for new_config in new_config_list %}
                                        <tr>
                                            <td>
                                                <span>{{ new_config.id }}</span>
                                            </td>
                                            <td>
                                                <span>{{ new_config.savename }}</span>
                                            </td>
                                            <td>
                                                <span>{{ new_config.create_time }}</span>
                                            </td>
                                            <td>
                                                <span>{{ new_config.update_time }}</span>
                                            </td>
                                            <td>
                                                <span>{{ new_config.create_by.real_name }}</span>
                                            </td>
                                            <td class="btn-group">
                                                {#                                                <button v-if="config._status == 2 || config._status == 5" type="button"#}
                                                {#                                                        value="[[ config.id ]]" class="btn btn-info btn-xs"#}
                                                {#                                                        onclick="deleteOneConfig([[ config.id ]])">删除#}
                                                {#                                                </button>#}
                                                <button type="button"
                                                        class="btn btn-info btn-xs"><a
                                                        href="{% url 'maintain:config_add_new_change' task.id  new_config.id %}"
                                                        style="color: white">详情</a>
                                                </button>
                                                <button v-if="task.status.code == 2 || task.status.code == 5"
                                                        type="button"
                                                        value="[[ new_config.id ]]" class="btn btn-info btn-xs"
                                                        onclick="deleteOneConfig({{ new_config.id }})">删除
                                                </button>
                                            </td>
                                        </tr>
                                    {% endfor %}
                                    </tbody>
                                </table>
                            </div>

                            <div class="box-footer">
                                <div class="input-group">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                {% if task.status.code == 5 %}
                    <div style="margin-top:20px;">
                        <b>不合格原因:{{ task.disqualify_reason_new }} 补充描述:{{ task.disqualify_reason }}</b>
                    </div>
                {% endif %}
                <div class="row">
                    <div class="col-md-12">
                        <!-- DIRECT CHAT -->
                        <div class="box box-primary direct-chat direct-chat-primary collapsed-box">
                            <div class="box-header with-border">
                                <h3 class="box-title">审核记录</h3>
                                <div class="box-tools pull-right">
                                <span data-toggle="tooltip" title="{{ communicatesNum }} Messages"
                                      class="badge bg-blue">{{ review_log_count }}</span>
                                    <button type="button" class="btn btn-box-tool" data-widget="collapse"><i
                                            class="fa fa-plus"></i>
                                    </button>
                                </div>
                            </div>
                            <div class="box-body">
                                <table id="auditRecordTable" border="1"
                                       class="table table-bordered table-hover table-striped">
                                    <thead>
                                    <tr>
                                        <th class="action-checkbox" style="width: 100px;">
                                        <span style="float: left">
                                            审核时间
                                        </span>
                                        </th>
                                        <th class="action-checkbox" style="width: 50px;">
                                        <span style="float: left">
                                            审核动作
                                        </span>
                                        </th>
                                        <th style="width: 800px;">
                                        <span style="float: left">
                                            原因描述
                                        </span>
                                        </th>
                                        <th style="width: 100px;">
                                        <span style="float: left">
                                            配置人员
                                        </span>
                                        </th>
                                        <th style="width: 100px;">
                                        <span style="float: left">
                                            审核人员
                                        </span>
                                        </th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    {% for review_log in review_log_list %}
                                        <tr>
                                            <td>
                                                <span>{{ review_log.ctime|timestamp_format:'%Y-%m-%d %H:%M:%S' }}</span>
                                            </td>
                                            <td>
                                                <span>{{ review_log.status }}</span>
                                            </td>
                                            <td>
                                                <span>{{ review_log.content }}</span>
                                            </td>
                                            <td>
                                                <span>{{ review_log.author }}</span>
                                            </td>
                                            <td>
                                                <span>{{ review_log.auditor }}</span>
                                            </td>
                                        </tr>
                                    {% endfor %}
                                    </tbody>
                                </table>
                            </div>

                            <div class="box-footer">
                                <div class="input-group">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <!--  审核记录 end  -->
                <div class="form-group">
                    <div style="float: left; color: red;">
                        <label for="" class="control-label">选中列表页：</label>
                        <input type="checkbox" name="th_checkbox_list_all" class="th_checkbox_list_all"
                               value="[[ message.check_result ]]"
                               onclick="checkMany(this, 'td_checkbox_list')">
                        <label for="" class="control-label">选中详情页：</label>
                        <input type="checkbox" name="th_checkbox_detail_all" class="th_checkbox_detail_all"
                               value="[[ message.check_result ]]"
                               onclick="checkMany(this, 'td_checkbox_detail')">
                        <span id="message" style="margin-right: 20px"></span>
                        {% if manage_type == 'task_detail_staff' %}
                            {% if task.status_id == 3 or task.status_id == 6 %}
                                {% if task.is_affirm == 1 or user.is_superuser  or  user.is_agent %}
                                    <button style="margin-left:20px;" type="button" class="btn btn-primary"
                                            onclick="feedback_result()">
                                        反馈结果
                                    </button>
                                {% endif %}
                            {% endif %}
                        {% elif manage_type == 'task_detail_agent' %}
                            {% if task.status_id == 4 or task.status_id == 6 %}
                                <button style="margin-left:20px;" type="button" class="btn btn-primary"
                                        onclick="BubbleTooltip('qualified', '{{ task.id }}')">
                                    合格
                                </button>
                            {% endif %}
                            {% if task.status_id == 4 or task.status_id == 5 %}
                                <button style="margin-left:20px;" type="button" class="btn btn-primary"
                                        onclick="BubbleTooltip('disqualified', '{{ task.id }}')">
                                    不合格
                                </button>
                            {% endif %}
                        {% elif manage_type == 'task_detail_admin' %}
                            {% if task.status_id == 4 or task.status_id == 5 or task.status_id == 6 %}
                                <button style="margin-left:20px;" type="button" class="btn btn-primary"
                                        onclick="BubbleTooltip('pass', '{{ task.id }}')">
                                    通过
                                </button>
                            {% endif %}
                            {#                            {% if task.status_id == 4 or task.status_id == 5 or task.status_id == 14 %}#}
                            {#                                <button style="margin-left:20px;" type="button" class="btn btn-primary"#}
                            {#                                        onclick="BubbleTooltip('disqualified', '{{ task.id }}')">#}
                            {#                                    不合格#}
                            {#                                </button>#}
                            {#                            {% endif %}#}
                            <!--                        <button style="margin-left:20px;" type="button" class="btn btn-primary" onclick="BubbleTooltip('recycle', '{{ task.id }}')">-->
                            <!--                            回收并反馈-->
                            <!--                        </button>-->
                        {% endif %}
                        {% for item in maintain_info_queryset %}
                            <label for="" class="control-label">{{ item.check_result }}</label>
                            <input type="checkbox" name="th_checkbox_detail_all" class="th_checkbox_detail_all"
                                   value="[[ message.check_result ]]"
                                   onclick="checkF(this, '{{ item.check_result_code }}')">
                        {% endfor %}
                    </div>
                    <span style="color: #00a7d0;margin-left: 10px"></span>
                </div>

                <!--模板变更信息展示--start-->
                <div class="form-group" id="messageList">
                    <table id="message_each_table" border="1" class="table table-bordered table-hover table-striped">
                        <thead>
                        <tr>
                            <th class="action-checkbox">
                                <input type="checkbox" name="th_checkbox_all" onclick="checkAll(this)">
                            </th>
                            <th v-for="head in headers">
                            <span style="float: left">
                                [[ head.name ]]
                            </span>
                            </th>
                            <!--                        <th>-->
                            <!--                            <span style="float: left">-->
                            <!--                                操作-->
                            <!--                            </span>-->
                            <!--                        </th>-->
                        </tr>
                        </thead>
                        <tbody>
                        <template v-for="message in message_list">
                            <tr>
                                <td class="action-checkbox">
                                    <input v-if="message.check_result.indexOf('列表页') != -1" type="checkbox"
                                           name="td_checkbox_list" class="td_checkbox" value="[[ message.id ]]"
                                           onclick="checkOne(this)">
                                    <input v-else type="checkbox" name="td_checkbox_detail" class="td_checkbox"
                                           value="[[ message.id ]]" onclick="checkOne(this)">
                                </td>
                                <template v-for="head in headers">
                                    <td v-if="head.key == 'detail_url' || head.key == 'channel_url'">
                                        <a href="[[ message[head.key] ]]" target="_blank"
                                           title="[[ message[head.key] ]]">[[ truncatechars(message[head.key], 80)
                                            ]]</a>
                                    </td>
                                    <td v-else>[[ message[head.key] ]]</td>
                                </template>
                            </tr>
                        </template>
                        </tbody>
                    </table>
                    <div>
                        {% if task.status_id == 3 or task.status_id == 6 %}
                            <a v-if="message_list.length == 0" class="btn btn-primary" data-toggle="modal"
                               data-target="#submitAudit">完成任务</a>
                        {% endif %}
                    </div>
                </div>
                <!--模板变更信息展示--end-->
                <!--确认删除配置弹出框-->
                <div class="modal fade" id="delete-config-window" tabindex="-1" role="dialog"
                     aria-labelledby="myModalLabel" style="top:30%">
                    <div class="modal-dialog" role="document">
                        <div class="panel panel-danger">
                            <div class="panel-heading">
                                <h3 class="panel-title">确认要删除配置吗？</h3>
                            </div>
                            <div class="modal-footer">
                                <button type="button" id="cancel_delete" class="btn btn-default"
                                        data-dismiss="modal">取消
                                </button>
                                <span id="submit-delete" class="btn btn-default" onclick="deleteConfigs()">
                        确定
                    </span>
                            </div>
                        </div>
                    </div>
                </div>
                <br>
            </div>
        </div>
    </div>

    <!--弹出任务提交审核提示消息-->
    <div class="modal fade" id="submitAudit" tabindex="-1" role="dialog"
         aria-labelledby="myModalLabel" style="top:40%">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">
                        确定要提交审核吗?
                    </h4>
                </div>
                <div id="msgBoxMsg" class="modal-body" style="overflow:auto;text-align:center;">
                    如修改过代码请点击<b>修改提交</b>，否则点击<b>反馈提交</b>
                </div>
                <div class="modal-footer" style="text-align:center;">
                    <button type="button" class="btn btn-default" onclick="submit_audit('{{ task.id }}', 1)"
                            data-dismiss="modal">修改提交
                    </button>
                    <button type="button" class="btn btn-default" onclick="submit_audit('{{ task.id }}', 0)"
                            data-dismiss="modal">反馈提交
                    </button>
                </div>
            </div>
        </div>
    </div>

    <!--反馈结果--start-->
    <div class="modal fade" id="feedbackList" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" style="top:5%">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-body" style="overflow:auto">
                    <label>反馈结果：</label>
                    <table id="feedback_each_table" border="1" class="table table-bordered table-hover table-striped">
                        <thead>
                        <tr>
                            <th class="action-checkbox">
                            </th>
                            <th>
                            <span style="float: left">
                                反馈结果
                            </span>
                            </th>
                        </tr>
                        </thead>
                        <tbody>
                        <template v-for="feedback in feedbackL_data_list">
                            <tr>
                                <td class="action-checkbox">
                                    <input id="feedback_radio_[[feedback.id]]" type="radio" name="feedback_radio"
                                           value="[[ feedback.id ]]">
                                </td>
                                <td>
                                    <label for="feedback_radio_[[ feedback.id ]]"
                                           class="control-label">[[ feedback.flag ]]</label>
                                </td>
                            </tr>
                        </template>
                        <tr>
                            <td class="action-checkbox">备注</td>
                            <td><textarea class="form-control" id="feedback_remake"></textarea>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal" onclick="_feedback_result()">确认
                    </button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消
                    </button>
                </div>
            </div>
        </div>
    </div>
    <!--反馈结果--end-->

    <!--提示消息--start-->
    <div class="modal fade" id="disposalMessage" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         style="top:40%">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div id="disposalMsgBoxMsg" class="modal-body" style="overflow:auto;text-align:center;">
                    <h4 id="promptMessage">提示消息</h4>
                    <input style="width:400px;height:100px;display:none" type="text" id="feedbackMessage"
                           placeholder="">
                </div>
                <div class="modal-footer" style="text-align:center;">
                    <button type="button" class="btn btn-default" data-dismiss="modal" id="confirm_button">确认
                    </button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                </div>
            </div>
        </div>
    </div>
    <!--提示消息--end-->
    <div class="modal fade" id="operationMessage1" tabindex="-1" role="dialog"
         aria-labelledby="myModalLabel" style="top:40%">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header" style="background-color: #307095;font-weight: bold;">
                    <label>请输入申请"误审"的原因：</label>
                </div>

                <div id="msgBoxMsg" class="modal-body" style="overflow:auto;text-align:center;">

                    <input style="width:400px;height:100px;" type="text" id="fankui" name="fankuiyy"/>

                </div>
                <div class="modal-footer" style="text-align:center;">
                    <button type="button" class="btn btn-default" onclick="distortActionNodePass()"
                            data-dismiss="modal">确认
                    </button>

                    <button type="button" class="btn btn-default"
                            data-dismiss="modal">取消
                    </button>
                </div>
            </div>
        </div>
    </div>

    <!--提示消息--start-->
    <div class="modal fade" id="code_comparison" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         style="top:40%">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div id="disposalMsgBoxMsg" class="modal-body" style="overflow:auto;text-align:center;">
                    <h4 id="promptMessage">代码比对</h4>
                </div>
                <div class="box-body">
                    <table id="auditRecordTable" border="1"
                           class="table table-bordered table-hover table-striped">
                        <thead>
                        <tr>
                            <th class="action-checkbox">
                                        <span style="float: left">

                                        </span>
                            </th>
                            <th class="action-checkbox">
                                        <span style="float: left">
                                            版本
                                        </span>
                            </th>
                            <th class="action-checkbox">
                                        <span style="float: left">
                                            时间
                                        </span>
                            </th>
                            <th style="width: 200px;">
                                        <span style="float: left">
                                            修改人
                                        </span>
                            </th>
                        </tr>
                        </thead>
                        <tbody>
                        {% for config_code in config_code_list %}
                            <tr>
                                <td>
                                    <input type="checkbox" name="th_checkbox_detail_all" class="th_checkbox_detail_all"
                                           value="[[ config_code.id]]"
                                           onclick="check_code(this, '{{ config_code.id }}')"></td>
                                <td>
                                    <span>{{ config_code.id }}</span>
                                </td>
                                <td>
                                    <span>{{ config_code.create_time }}</span>
                                </td>
                                <td>
                                    <span>{{ config_code.create_by.username }}</span>
                                </td>
                            </tr>
                        {% endfor %}
                        </tbody>
                    </table>
                </div>
                <div class="modal-footer" style="text-align:center;">
                    <button type="button" class="btn btn-default" data-dismiss="modal" id="confirm_button"
                            onclick="history_code()">确认
                    </button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                </div>
            </div>
        </div>
    </div>


    <input id="taskIds" value="" style="display:none;"></input>


    <script>
        $("#myTasks").addClass("active");
        Vue.config.delimiters = ["[[", "]]"];
        var code_data_list = []
        var messageListVue = new Vue({
            el: "#messageList",
            data: {
                headers: [],
                message_list: [],
                message: "",
                check_result_code_list: [],
                feedback_list_list: [],
            },
            methods: {
                parseTime: function (timeStamp) {
                    if (!timeStamp) {
                        return ""
                    }
                    var newDate = new Date();
                    newDate.setTime(timeStamp * 1000);
                    return newDate.toLocaleDateString()
                },
                truncatechars: function (str, end) {
                    if (!str) {
                        return ""
                    }
                    if (end <= str.length) {
                        return str.slice(0, end) + '...'
                    } else {
                        return str
                    }
                }
            }
        });
        var feedback_rea_list = new Vue({
            el: "#feedbackList",
            data: {
                feedbackL_data_list: []
            },
            methods: {}

        });

        function getMessages() {
            var task_detail_api = "{{ task_detail_api }}";
            $.ajax({
                url: task_detail_api,
                type: 'POST',
                data: {
                    csrfmiddlewaretoken: "{{ csrf_token }}",
                    task_id: "{{ task_id }}"
                },
                success: function (response) {
                    messageListVue.headers = response.headers;
                    messageListVue.message_list = response.message_list;
                }
            });
        }

        getMessages(messageListVue);

        // 选中全部
        function checkAll(obj) {
            if ($(obj).is(":checked")) {
                $("input[name='td_checkbox_list']").prop("checked", true);
                $("input[name='td_checkbox_detail']").prop("checked", true);
                $("input[class='th_checkbox_list_all']").prop("checked", true);
                $("input[class='th_checkbox_detail_all']").prop("checked", true);
            } else {
                $("input[name='td_checkbox_list']").prop("checked", false);
                $("input[name='td_checkbox_detail']").prop("checked", false);
                $("input[class='th_checkbox_list_all']").prop("checked", false);
                $("input[class='th_checkbox_detail_all']").prop("checked", false);
            }
        }

        // 选中多个
        function checkMany(obj, check_name) {
            console.log(obj)
            if ($(obj).is(":checked")) {
                $("input[name=" + check_name + "]").prop("checked", true);
            } else {
                $("input[name=" + check_name + "]").prop("checked", false);
            }
            checkOne();
        }

        function checkF(obj, info_name) {
            if ($(obj).is(":checked")) {
                for (message in messageListVue.message_list) {
                    if (messageListVue.message_list[message].check_result_code === info_name) {
                        console.log(messageListVue.message_list[message].id)
                        $("input[value=" + messageListVue.message_list[message].id + "]").prop("checked", true);
                        messageListVue.check_result_code_list.push(info_name)
                    }

                }
            } else {
                for (message in messageListVue.message_list) {
                    if (messageListVue.message_list[message].check_result_code === info_name) {
                        $("input[value=" + messageListVue.message_list[message].id + "]").prop("checked", false);
                        messageListVue.check_result_code_list.$remove(info_name)
                    }
                }
            }
        }

        function check_code(obj, info_name) {
            if ($(obj).is(":checked")) {
                if (code_data_list.length === 2) {
                    alert('最多选择两个对比');
                    return false
                } else {
                    $("input[value=" + info_name + "]").prop("checked", true);
                    code_data_list.push(info_name)
                }

            } else {
                console.log(code_data_list)
                $("input[value=" + info_name + "]").prop("checked", false);
                code_data_list.$remove(info_name)
            }
        }


        // 选中一个
        function checkOne(obj) {
            if ($("input[name='th_checkbox_all']").is(":checked")) {
                $("input[name='th_checkbox_all']").prop("checked", false)
            } else {
                var unChecked = true;
                $("input[class='td_checkbox']").each(
                    function () {
                        if (!$(this).is(":checked")) {
                            unChecked = false;
                        }
                    }
                );
                if (unChecked) {
                    $("input[name='th_checkbox_all']").prop("checked", true)
                }
            }
        }

        // 反馈结果
        function feedback_result() {
            feedback_list = [];
            $("input[class='td_checkbox']:checked").each(
                function () {
                    feedback_list.push($(this).val());
                }
            );
            // 判断是否选中链接
            if (feedback_list.length === 0) {
                alert('没有选中链接');
                return false;
            }
            $.ajax({
                url: "{% url 'maintain:get_filter_feedback' %}",
                type: 'POST',
                data: {
                    csrfmiddlewaretoken: "{{ csrf_token }}",
                    check_result_code_list: JSON.stringify(messageListVue.check_result_code_list)
                },
                success: function (response) {
                    feedback_rea_list.feedbackL_data_list = response["feedback_data_list"];
                    console.log(feedback_rea_list.feedbackL_data_list)
                }
            });
            $("#feedbackList").modal();
            {#Vue.$forceUpdate()#}
        }

        function _feedback_result() {
            var flag = $("input[name='feedback_radio']:checked").val();
            var remake = $("#feedback_remake").val();
            var task_id = "{{ task_id }}";
            $.ajax({
                url: "{% url 'maintain:feedback_api' %}",
                type: "POST",
                dataType: "json",
                data: {
                    csrfmiddlewaretoken: "{{ csrf_token }}",
                    task_id: task_id,
                    flag: flag,
                    remake: remake,
                    feedback_list: JSON.stringify(feedback_list),
                },
                success: function (resp) {
                    alert(resp.message);
                    location.reload();
                }
            })
        }

        // 提交审核
        function submit_audit(task_id, is_modify) {
            $.ajax({
                url: "{% url 'maintain:submit_audit' %}",
                type: "POST",
                data: {
                    csrfmiddlewaretoken: "{{ csrf_token }}",
                    task_id: task_id,
                    is_modify: is_modify
                },
                success: function (resp) {
                    alert(resp.message);
                    location.reload();
                }
            })
        }

        function test_maintain_config(tid) {
            $.ajaxSetup({
                data: {
                    csrfmiddlewaretoken: '{{ csrf_token }}',
                    tids: tid
                }
            });
            $.post(
                "{% url 'maintain:task_maintain_test_config' %}",
                function (response) {
                    //console.log(response);
                    {#toPage(response, -1)#}
                    var sec = 2000;
                    var message = response.message;
                    var result = response.result;
                    var $message = $("#message");
                    if (message) {
                        $message.text(message);
                    }
                }
            )
        }

        function task_affirm(tid) {
            $.ajaxSetup({
                data: {
                    csrfmiddlewaretoken: '{{ csrf_token }}',
                    tids: tid
                }
            });
            $.post(
                "{% url 'maintain:task_affirm' %}",
                function (response) {
                    //console.log(response);
                    {#toPage(response, -1)#}
                    var sec = 2000;
                    var message = response.message;
                    var result = response.result;
                    var $message = $("#message");
                    if (message) {
                        $message.text(message);
                    }
                    window.location.reload();
                }
            )
        }

        function BubbleTooltip(type, task_id) {
            switch (type) {
                case 'qualified':
                    var change_status_api = "{% url 'maintain:qualified' %}";
                    $('#promptMessage').html("确定修改为合格吗？");
                    $('#confirm_button').attr("onclick", "changeStatus(" + task_id + ",'" + change_status_api + "')");
                    break;
                case 'disqualified':
                    var change_status_api = "{% url 'maintain:disqualified' %}";
                    $('#promptMessage').html("确定修改为不合格吗？");
                    $('#confirm_button').attr("onclick", "changeStatus(" + task_id + ",'" + change_status_api + "')");
                    $('#feedbackMessage').css("display", "block");
                    break;
                case 'pass':
                    var change_status_api = "{% url 'maintain:passed' %}";
                    $('#promptMessage').html("确定通过吗？");
                    $('#confirm_button').attr("onclick", "changeStatus(" + task_id + ",'" + change_status_api + "')");
                    break;
                case 'recycle':
                    var change_status_api = "{% url 'maintain:recycle' %}";
                    $('#promptMessage').html("确定回收吗？");
                    $('#confirm_button').attr("onclick", "changeStatus(" + task_id + ",'" + change_status_api + "')");
                    $('#feedbackMessage').css("display", "block");
                    break;
            }
            $('#disposalMessage').modal();
        }

        // 修改状态
        function changeStatus(task_id, change_status_api) {
            var feedbackMessage = $("#feedbackMessage").val();
            $.ajax({
                url: change_status_api,
                type: "POST",
                data: {
                    csrfmiddlewaretoken: "{{ csrf_token }}",
                    task_id: task_id,
                    feedbackMessage: feedbackMessage
                },
                success: function (resp) {
                    alert(resp.message);
                    location.reload();
                }
            })
        }

        var _cids;

        function deleteOneConfig(cid) {
            //$("#configIds").val(cid);
            _cids = cid;
            $("#delete-config-window").modal();
        }

        function deleteConfigs(cids) {
            if (!cids) {
                cids = _cids
            }
            if (!cids) {
                alert("请给出要删除的配置ID！")
            } else {
                $.ajaxSetup({
                    data: {
                        csrfmiddlewaretoken: '{{ csrf_token }}',
                        cids: cids
                    }
                });
                $.post(
                    "{% url 'maintain:delete_config' %}",
                    function (response) {
                        if (response.message) {
                            alert(response.message);
                        }
                        window.location.reload();
                        _cids = null;
                    }
                )
            }
        }

        function alarms_fail(tids) {
            if (tids) {
                $("#taskIds").val(tids);
                $("#operationMessage1").modal();
            } else {
                return false
            }
        }

        // 误审不通过
        function distortActionNodePass() {
            var tids = $("#taskIds").val();
            var fankui = $("#fankui").val();
            $.post({
                url: "{% url 'maintain:re_audit' %}",
                data: {
                    csrfmiddlewaretoken: "{{ csrf_token }}",
                    task_id: tids,
                    reason: fankui
                },
                success: function (resp) {
                    var result = resp.message;
                    alert(result)
                },
                error: function () {
                    alert('误审标记失败')
                }
            });

        }

        function code_1() {
            $("#code_comparison").modal();
        }

        function history_code() {
            console.log(code_data_list)
            if (code_data_list.length !== 2) {
                alert('请选择两个对比！')
                return false
            }

            window.open("{% url 'maintain:change_history'%}" + "?p_code_data_1=" + code_data_list[0] + "&p_code_data_2=" + code_data_list[1])

        }
    </script>
{% endblock section_content %}